<template>
	<component :is="whichComponent" ref="formRef"></component>
</template>

<script setup>
import { contractApi } from "@/api/assets";
import Template1 from "./components/template1.vue";
import TemplateWuYe from "./components/templateWuYe.vue";
import TemplateYiZhan from "./components/templateYiZhan.vue";
import { onMounted, shallowRef } from "vue";
import { useRoute, useRouter } from "vue-router";
let whichComponent = shallowRef(null);
const router = useRouter();

const getTemplateTy = (contractTemplateId) => {
	switch (contractTemplateId) {
		case "1":
		case "2":
		case "3":
		case "4":
			whichComponent.value = Template1;
			break;
		case "5":
			console.log(5);
			whichComponent.value = TemplateWuYe;
			break;
		case "6":
			whichComponent.value = TemplateYiZhan;
			break;
		default:
			break;
	}
};

onMounted(() => {
	const getContractId = router.currentRoute.value.params.contractId;
	contractApi
		.getCheckupInfo({
			contractId: getContractId,
		})
		.then((res) => {
			if (res.code != 200) {
				return;
			}
			getTemplateTy(res.data.contractTemplateId)

		});
});
</script>

<style lang="scss" scoped></style>
